//
//  BaseViewController.m
//  BaseProject
//
//  Created by zhangrongbing on 16/9/26.
//  Copyright © 2016年 lovcreate. All rights reserved.
//

#import "BaseViewController.h"
#import "BaseNavigationViewController.h"
#import "UIImage+GIF.h"
@interface BaseViewController ()

@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _config = [MyConfig sharedMyConfig];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

-(NetworkingManager*)networkingManager{
    if (!_networkingManager) {
        _networkingManager = [[NetworkingManager alloc] init];
    }
    return _networkingManager;
}

//访问网络的菊花
-(MBProgressHUD*)hud{
    if (!_hud) {
        _hud = [[MBProgressHUD alloc] initWithFrame:self.view.bounds];
        _hud.removeFromSuperViewOnHide = YES;
        _hud.backgroundView.style = MBProgressHUDBackgroundStyleSolidColor;
        _hud.backgroundView.color = [[UIColor grayColor] colorWithAlphaComponent:.4];
//        _hud.mode = MBProgressHUDModeCustomView;
//        //显示自定义gif
//        _hud.customView = [[UIImageView alloc]initWithImage:[UIImage sd_animatedGIFNamed:@"加载008"]];
        
        
  
        _hud.mode = MBProgressHUDModeIndeterminate;
    }
   
    return _hud;
  
}

//-(void)presentToController:(BaseViewController*)controller{
//    UIBarButtonItem* backItem = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(dismiss)];
//    controller.navigationItem.leftBarButtonItem = backItem;
//    BaseNavigationViewController* navController = [[BaseNavigationViewController alloc] initWithRootViewController:controller];
//    [self presentViewController:navController animated:YES completion:nil];
//}
//
//-(void)dismiss{
//    [MBProgressHUD hideHUDForView:self.view animated:YES];
//    [self dismissViewControllerAnimated:YES completion:nil];
//}

-(void)showToastMessage:(NSString*)message{
    UIApplication* application = [UIApplication sharedApplication];
    _toastHud = [MBProgressHUD showHUDAddedTo:application.keyWindow animated:YES];
    if (!_toastHud) {
        _toastHud = [MBProgressHUD showHUDAddedTo:application.keyWindow animated:YES];
    }
    _toastHud.mode = MBProgressHUDModeText;
    _toastHud.label.text = message;
    _toastHud.offset = CGPointMake(0, MBProgressMaxOffset);
    [_toastHud hideAnimated:YES afterDelay:1.5];
}
@end
